package cn.mesmile.security.mapper;

import cn.mesmile.security.domain.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author zb
 * @date 2020/4/5 16:02
 * @Description:
 */
public interface RoleMapper extends BaseMapper<Role> {


    /**
     *  通过用户id,查找到其所拥有的角色
     * @param eid
     * @return
     */
    @Select("SELECT\n" +
            " r.*\n" +
            "FROM\n" +
            "\trole AS r\n" +
            "LEFT JOIN employee_role AS er ON r.id = er.rid\n" +
            "LEFT JOIN employee AS e ON er.eid = e.id WHERE e.id=#{eid}")
    List<Role> findByEid(@Param("eid") String eid);

}
